import { post } from '@/utils/request'

export default {
  list: query => post('/api/student/company/list'),
  pageList: query => {
    // Convert query object to URL parameters
    const params = new URLSearchParams();

    // Only add parameters that have values
    if (query.title) params.append('title', query.title);
    if (query.companyName) params.append('companyName', query.companyName);
    if (query.mbtiType) params.append('mbtiType', query.mbtiType);
    if (query.pageNum) params.append('pageNum', query.pageNum);
    if (query.pageSize) params.append('pageSize', query.pageSize);

    // Create the URL with query parameters
    const url = `/api/student/company/list?${params.toString()}`;

    // Send an empty object as the body since we're using query parameters
    return post(url, {});
  },
  edit: query => post('/api/student/company/edit', query),
  select: id => post('/api/student/company/select/' + id),
  deleteSubject: id => post('/api/student/company/delete/' + id),
  applyJob: data => post('/api/student/jobApplication/create', data)
}
